package com.gzz.orchid.context.infrastructure.definition;

import com.gzz.orchid.common.core.support.IBaseEnum;


/**
 * 状态枚举
 */
public enum Status implements IBaseEnum {
    // 创建
    CREATED(0, "status.created"),
    // 提交
    SUBMITTED(1, "status.submitted"),
    // 禁用
    DISABLED(2, "status.disabled"),
    // 启用
    ENABLED(3, "status.enabled"),
    // 销毁
    DESTROYED(9, "status.destroyed");

    private final int code;
    private final String text;

    Status(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static Status parse(int val) {
        for (Status e : Status.values()) {
            if (e.code == val) {
                return e;
            }
        }
        throw new IllegalArgumentException("Invalid Status value: " + val);
    }

    public static Status of(String name) {
        return Enum.valueOf(Status.class, name);
    }

    @Override
    public Integer getValue() {
        return this.code;
    }

    @Override
    public String getLabel() {
        return this.text;
    }
}
